// /?name=zhangsan          => { name: zhangsan }
// /?name=zhangsan&age=18   => { name: zhangsan, age: 18 }

// const str = "/?name=zhangsan";

// const str1 = str.split("?")[1];
// console.log(str1);
// const arr = str1.split("=");
// console.log(arr);
// const result = {};
// result[arr[0]] = arr[1];
// console.log(result);

const str = "/?name=zhangsan&age=18";
const str1 = str.split("?")[1]; // name=zhangsan&age=18

const arr = str1.split("&"); // ['name=zhangsan', 'age=18']
const result = {};

for (let i = 0; i < arr.length; i++) {
  const item = arr[i]; // name=zhangsan    age=18

  const temp = item.split("="); // ['name', 'zhangsan']  ['age', '18']

  result[temp[0]] = temp[1];
}

console.log(result);

console.log("/".split("?"));
